package com.kuqi.Utils;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Miscellaneous {

    /**
     * 判断日期是不是已经过了可用时期
     * @param startDate 注册时间
     * @param keepDay 生效时间
     * @return 当前是否还在生效
     */
    public static boolean checkPastDue(Date startDate, int keepDay){
        Calendar last = Calendar.getInstance();
        last.setTime(startDate); // 设置时间
        last.add(Calendar.DAY_OF_MONTH, keepDay); // 时间+可用天
        Calendar now = Calendar.getInstance();
        // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // System.out.println(sdf.format(now.getTime()));
        // System.out.println(sdf.format(last.getTimeInMillis()));
        // System.out.println(last.before(now));
        return last.before(now);
    }


}